package com.googlecode.vmock;

import com.googlecode.vmock.utils.Validate;

/**
 * A call result that is expected to throw a given throwable.
 * 
 * @author marcin.jagus
 */
class ThrowCallResult extends AbstractExpectedCallResult {

    /**
     * Throwable that is expected to be thrown.
     */
    private Throwable expectedThrowable;

    /**
     * Creates new result for a given call with a given throwable.
     * 
     * @param expectedThrowable A given throwable
     * @param recordedCall A given recorded call
     */
    public ThrowCallResult(Throwable expectedThrowable, RecordedCall recordedCall) {
        super(recordedCall);
        Validate.notNull(expectedThrowable, "expectedThrowable == null");

        this.expectedThrowable = expectedThrowable;
    }

    @Override
    public Object getResult(Object[] params) throws Throwable {
        incrementTimesInvoked();
        throw expectedThrowable;
    }

}
